﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Task.Common.Interface;
using Common.Service;
using System.Collections;
using Task.Common.Entity;
using System.Data;


namespace Task
{
    public partial class NewTask2 : System.Web.UI.Page
    {
        Task.Common.Interface.IDictionary dictionary = ServiceContainer.GetService<Task.Common.Interface.IDictionary>();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Index = "0";
                BindProcessCatalog();
            }
        }

        protected void BindProcessCatalog()
        {
            string where = "type!PROCESS_CATEGORY;";
            DataSet ds = dictionary.GetDictionaryData("DictionaryLogic_GetListByType", where);
            DataTable dt = ds.Tables[0];
            dt.Columns.Add("display");
            dt.Columns.Add("CssClass");
            foreach (DataRow dr in dt.Rows)
            {
                dr["display"] = "none";
                //dr["CssClass"] = "";
            }
            DataRow row = dt.NewRow();
            row["DICTIONARY_ID"] = 0;
            row["CN_NAME"] = "所有";
            row["display"] = "";
            row["CssClass"] = "currently";
            dt.Rows.InsertAt(row, 0);

            rpProcessCatalog.DataSource = dt;
            rpProcessCatalog.DataBind();

            rpAllProcess.DataSource = dt;
            rpAllProcess.DataBind();
        }

        public string Index { get; set; }

        protected void rpAllProcess_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Repeater rpProcess = (Repeater)e.Item.FindControl("rpProcess");
                DataRowView rowView = (DataRowView)e.Item.DataItem;
                string dicID = Convert.ToString(rowView["DICTIONARY_ID"]);
                DataTable dt;
                string where = "type!PROCESS;";
                if (dicID == "0")
                {
                    dt = dictionary.GetDictionaryData("DictionaryLogic_GetListByType", where).Tables[0];
                }
                else
                {
                    dt = dictionary.GetDictionaryData("DictionaryLogic_GetListByDicID", "parentID!" + dicID).Tables[0];
                }

                rpProcess.DataSource = dt;
                rpProcess.DataBind();

            }
        }
    }
}